<?php

class Cats_product extends CI_Model {
//这个model处理分类和分类所包含提交的宝贝或者店铺活动的关系    

    const Statustrue = True;
    const Statusflase = False;

    function __construct() {
        $this->load->helper('fuc');
        $this->load->library('topclass');
        $this->config->load('sysetting');
        parent::__construct();
    }

    function get_cats() {
        $query = $this->db->get('cats');
        return $cats_array = $query->result_array();
    }

    function get_items() {
        $sql = "select cats.name ,prores.* from cats,prores where cats.id=prores.catid";
        $query = $this->db->query($sql);

        return $res = $query->result_array();
    }

    function get_items_byPost() {
        if (isset($_POST["catid"])) {
            $condition_catid = " and prores.catid={$_POST["catid"]}  ";
        } else {
            $condition_catid = "";
        }
        if (isset($_POST["typeid"])) {
            $condition_typeid = " and prores.type={$_POST["typeid"]}  ";
        } else {
            $condition_typeid = "";
        }
        if (isset($_POST["itemname"])) {
            $condition_itemname = " and prores.itemname like \"%{$_POST["itemname"]}%\" ";
        } else {
            $condition_itemname = "";
        }
        $sql = "select cats.name ,prores.* from cats,prores where cats.id=prores.catid";
        echo $sql = $sql . $condition_catid . $condition_typeid . $condition_itemname;
        $query = $this->db->query($sql);

        return $res = $query->result_array();
    }

    function get_itemsdetail($id) {
        $sql = "select * from prores where id=\"{$id}\"";
        $query = $this->db->query($sql);
        return $res = $query->result_array();
    }

    function get_items_types() {
        return $items_types_arrays = $this->config->item('submit_type');
        //  return $res = $query->result_array();
    }
    
    
    

}

?>
